package cn.edu.gzist.chapter08.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitMQConfig {
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
    // 1.定义fanout类型的交换机
   /* @Bean
    public Exchange pubsubExchange(){
        return ExchangeBuilder.fanoutExchange("pub/sub.exchange").build();
    }
    // 2.定义两个不同名称的消息队列
    @Bean
    public Queue emailQueue(){
        return new Queue("email.queue");
    }
    @Bean
    public Queue ssmQueue(){
        return new Queue("sms.queue");
    }
    // 3.将两个不同名称的消息队列与交换机进行绑定
    @Bean
    public Binding bindingEmail(){
        return
                BindingBuilder.bind(emailQueue()).to(pubsubExchange()).with("").noargs();
    }
    @Bean
    public Binding bindingSms(){
        return
                BindingBuilder.bind(ssmQueue()).to(pubsubExchange()).with("").noargs();
    }*/
}